package org.liux.android.game.jumpgame.character;

public class HookRight extends Shape {
	
	public static final int STATE_1 = 0;
	public static final int STATE_2 = 1;
	public static final int STATE_3 = 2;
	public static final int STATE_4 = 3;
	
	/**   STATE_1                               STATE_2                               STATE_3                             STATE_4
	 *          
	 *     #                                            #  #                                   #   #  #                                         #
	 *     # # #                                      #                                                #                                         #
	 *                                                   #                                                                                       #  #
	 */
	
	@Override
	public void change(Coordinate c) {
		int x = c.x;
		int y = c.y;
		
		if (mShapeList.size() > 0) {
			mShapeList.clear();
		}
		
		if(mState == STATE_1){
			mShapeList.add(new Coordinate(x+1, y));
			mShapeList.add(new Coordinate(x, y));
			mShapeList.add(new Coordinate(x, y+1));
			mShapeList.add(new Coordinate(x, y+2));
			mOldState = mState;
			mState=STATE_2;
			return;
		}
		
		if(mState == STATE_2){
			mShapeList.add(new Coordinate(x, y+1));
			mShapeList.add(new Coordinate(x, y));
			mShapeList.add(new Coordinate(x-1, y));
			mShapeList.add(new Coordinate(x-2, y));
			mOldState = mState;
			mState=STATE_3;
			return;
		}
		
		if(mState == STATE_3){
			mShapeList.add(new Coordinate(x-1, y));
			mShapeList.add(new Coordinate(x, y));
			mShapeList.add(new Coordinate(x, y-1));
			mShapeList.add(new Coordinate(x, y-2));
			mOldState = mState;
			mState=STATE_4;
			return;
		}
		
		if(mState == STATE_4){
			mShapeList.add(new Coordinate(x, y-1));
			mShapeList.add(new Coordinate(x, y));
			mShapeList.add(new Coordinate(x+1, y));
			mShapeList.add(new Coordinate(x+2, y));
			mOldState = mState;
			mState=STATE_1;
			return;
		}

	}

	@Override
	public void initCoord() {
		mShapeList.add(new Coordinate(mMidWidth, 0));
		mShapeList.add(new Coordinate(mMidWidth, 1));
		mShapeList.add(new Coordinate(mMidWidth+1, 1));
		mShapeList.add(new Coordinate(mMidWidth+2, 1));

	}


}
